﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;              //命名空间
using System.Data.SqlClient;    //数据库头文件
using System.Data.Sql;         //数据库头文件
using DATA_operate_;          //自定义数据库操作类引用

public partial class design_page_student_Default : System.Web.UI.Page
{
    DATA_operate data_operate_in_myinfo = new DATA_operate();   //创建数据库操作类对象
   
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            HttpCookie cookie = Request.Cookies["stuid"];
            string str_sid = cookie.Value.ToString();
            string adminname = data_operate_in_myinfo.dataread("_student", "_Sname", "_Sid", str_sid);
            string adminsex = data_operate_in_myinfo.dataread("_student", "_Ssex", "_Sid", str_sid);
            string adminphone = data_operate_in_myinfo.dataread("_student", "_Sphone", "_Sid", str_sid);
            TextBoid.Enabled = false;
            DropDownListsex.Enabled = false;
            TextBoid.Text = str_sid;
            TextBoxname.Text = adminname;
            TextBoxphone.Text = adminphone;
            DropDownListsex.SelectedItem.Text = adminsex;

        }
    }
    protected void Button2_Click(object sender, EventArgs e)   //修改
    {
        HttpCookie cookie = Request.Cookies["stuid"];
        string str_sid = cookie.Value.ToString();
        string adminpwd = data_operate_in_myinfo.dataread("_student", "_Spwd", "_Sid", str_sid);
        adminpwd = adminpwd.Replace(" ", "");
        if (TextBoxfristpwd.Text == adminpwd)
        {
            data_operate_in_myinfo.Data_update("_student", "_Spwd", TextBoxnewpwd2.Text, "_Sid", str_sid);
            data_operate_in_myinfo.Data_update("_student", "_Sname", TextBoxname.Text, "_Sid", str_sid);
            data_operate_in_myinfo.Data_update("_student", "_Sphone", TextBoxphone.Text, "_Sid", str_sid);

            Page.ClientScript.RegisterStartupScript(this.GetType(), "right", "window.alert('修改成功');", true);

        }
        else
            Page.ClientScript.RegisterStartupScript(this.GetType(), "right", "window.alert('密码不正确');", true);


    }
    protected void Button3_Click(object sender, EventArgs e)   //置空
    {
        TextBoxfristpwd.Text = "";
        TextBoxnewpwd1.Text = "";
        TextBoxnewpwd2.Text = "";
        TextBoxname.Text = "";
        TextBoxphone.Text = "";
    }
}